***********************************************************************************************************************
* This is the code to replicate the results of the article "Political Budgetary Cycles in Autocratic Redistribution"
* To be run on:
* - replication_data_country.dta
* - replication_data_individual.dta
* Analyses of the article were done with Stata/MP 17.0 for Mac (Intel 64-bit)
***********************************************************************************************************************



**************************
* COUNTRY-LEVEL ANALYSIS *
**************************

cd "/Users/kangwookhan/Desktop/"

use "replication_data_country", clear

global est "eststo"
global dv "social_protection"
global iv "proximity c.proximity#c.proximity"
global cvs "L.wdi_pop1564 L.l_gdppc L.resources_dep L.wdi_gdpgr"
global fixed "i.ccode i.year"
global cond1 "(ea==1) & (l.democracy==0 & democracy==0) & year>=1970"
global cond2 "(ea==1) & (l.p_polity<6 & p_polity<6) & year>=1970"
global method "xtpcse"
global opt "het c(psar1)"


xtset ccode year

***********
* Table 1 *
***********

$est: $method $dv $fixed $iv if $cond1, $opt
est store model1
$est: $method $dv $fixed $iv $cvs if $cond1, $opt
test proximity c.proximity#c.proximity
$est: $method $dv $fixed $iv $cvs if $cond2, $opt

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) ///
order($ldv $iv $cvs _cons)
eststo clear

**********
* U-test *
**********

ge proximity2=proximity*proximity

$method $dv $fixed proximity proximity2 $cvs if $cond1, $opt
utest proximity proximity2

***********
* Table 2 *
***********

$est: $method defense $fixed $iv if $cond1, $opt
$est: $method defense $fixed $iv $cvs if $cond1, $opt

global speech "proximity c.proximity#c.proximity L.v2x_freexp cL.v2x_freexp#c.proximity cL.v2x_freexp#c.proximity#c.proximity"

$est: $method $dv $fixed $speech if $cond1, $opt
$est: $method $dv $fixed $speech $cvs if $cond1, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($speech $cvs _cons) order($speech $cvs _cons)
eststo clear

************
* Table A3 *
************

$est: $method $dv $fixed $iv if l.ea2==0 & ea2==0 & l.democracy==0 & democracy==0, $opt
$est: $method $dv $fixed $iv $cvs if l.ea2==0 & ea2==0 & l.democracy==0 & democracy==0, $opt

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) /*
*/order($ldv $iv $cvs _cons)
eststo clear

************
* Table A4 *
************

ge soc_def=social_protection/defense

$est: $method soc_def $fixed $iv if $cond1, $opt
$est: $method soc_def $fixed $iv $cvs if $cond1, $opt

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) /*
*/order($ldv $iv $cvs _cons)
eststo clear

************
* Table A5 *
************

bysort ccode elec_group: egen m_$dv=mean($dv) 

xtset ccode year

$est: $method $dv $fixed $iv $cvs if $cond1 & m_$dv<29.45 & m_$dv>0, het c(psar1)
$est: $method $dv $fixed $iv $cvs if $cond1 & m_$dv<23.2 & m_$dv>0.4, het c(psar1)

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) /*
*/order($iv $cvs _cons)
eststo clear

************
* Table A6 *
************

$est: $method $dv $fixed $iv $cvs if $cond1 & length<18.61 & length>0.37, $opt
$est: $method $dv $fixed $iv $cvs if $cond1 & length<8.92 & length>1.48, $opt

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) /*
*/order($iv $cvs _cons)
eststo clear

************
* Table A7 *
************

global cond3 "(ea==1) & (l.m_dem==0 & m_dem==0) & year>=1970"

$est: $method $dv $fixed $iv $cvs if $cond1 & ccode!=95 & ccode!= 437 ///
& ccode!= 439 & ccode!= 450 & ccode!= 451 & ccode!= 452 & ccode!= 482 ///
& ccode!= 516 & ccode!= 541 & ccode!= 580 & ccode!= 775, $opt
$est: $method $dv $fixed $iv $cvs if $cond3, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear

************
* Table A8 *
************

global cond4 "(legcompetn>=7 & legcompetn!=. & l.legcompetn>=7 & l.legcompetn!=.) & (l.democracy==0 & democracy==0) & year>=1970"
global cond5 "(legcompetn>=7 & legcompetn!=. & l.legcompetn>=7 & l.legcompetn!=.) & (l.p_polity<6 & p_polity<6) & year>=1970"

$est: $method $dv $fixed $iv $cvs if $cond4, $opt
$est: $method $dv $fixed $iv $cvs if $cond5, $opt

esttab, nogaps comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) /*
*/order($ldv $iv $cvs _cons)
eststo clear

************
* Table A9 *
************

global ged "L.gwf_party L.gwf_personal"
global ineq "L.gini_mkt"
global int "L.wdi_trade L.wdi_fdiin"

$est: $method $dv $fixed $iv $cvs $ged if $cond1, $opt
$est: $method $dv $fixed $iv $cvs $ineq if $cond1, $opt
$est: $method $dv $fixed $iv $cvs $int if $cond1, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs $ged $ineq $int _cons)
eststo clear

*************
* Table A10 *
*************

tab ccode, ge(cr_)

$est: $method $dv $fixed $iv $cvs if (ea==1) & (l.democracy==0 & democracy==0) & (l.fraud==0 & fraud==0) & year>=1970, $opt
$est: $method $dv $fixed $iv $cvs if (ea==1) & (l.democracy==0 & democracy==0) & (l.nfraud==0 & nfraud==0) & year>=1970, $opt
$est: $method $dv $fixed $iv $cvs if (ea==1) & (l.democracy==0 & democracy==0) & (l.irr_elec==0 & irr_elec==0) & year>=1970, $opt
$est: $method $dv cr_* i.year $iv $cvs if (ea==1) & (l.democracy==0 & democracy==0) & (l.r_elec==0 & r_elec==0) & year>=1970, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear

*************
* Table A11 *
*************

$est: $method $dv $fixed c.proximity##c.proximity $cvs if $cond1 & l_gdppc>=4.77 & l_gdppc!=., $opt
$est: $method $dv $fixed c.proximity##c.proximity $cvs if $cond1 & l_gdppc>=5.58 & l_gdppc!=., $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear

*************
* Table A19 *
*************

ge missing=1 if $dv==.
replace missing=0 if $dv!=.
$est: logit missing $iv $cvs if $cond1 , robust cluster(ccode)
$est: $method hrv_transparencyindex $fixed $iv $cvs if $cond1 , het c(psar1)

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear

*************
* Table A20 *
*************

global cbi "proximity c.proximity#c.proximity L.lvaw_garriga c.proximity#cL.lvaw_garriga c.proximity#c.proximity#cL.lvaw_garriga"
global res "proximity c.proximity#c.proximity L.resources_dep  c.proximity#cL.resources_dep c.proximity#c.proximity#cL.resources_dep"

$est: $method $dv $fixed $cbi $cvs if $cond1, $opt
$est: $method $dv $fixed $res $cvs if $cond1, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) ///
keep($fail $cbi $res $cvs _cons) order($fail $cbi $res $cvs _cons)
eststo clear

*************
* Table A21 *
*************

$est: $method $dv $fixed $iv $cvs if $cond1 & (L.localorgz==0) , $opt
margins, at(proximity=(0(0.05)1)) force noestimcheck

$est: $method $dv $fixed $iv $cvs if $cond1 & (L.localorgz==1 | L.localorgz==2) , $opt
margins, at(proximity=(0(0.05)1)) force noestimcheck

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) ///
keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear

*************
* Table A22 *
*************

global iv2 "non_election"
global iv3 "D.ELE L.ELE"
global ldv "L.social_protection"
global dif "D.wdi_pop1564 D.l_gdppc D.resources_dep D.wdi_gdpgr"
global opt2 "het"

$est: $method $dv $fixed $iv $cvs if $cond1 & d.expenditure>=0 & d.expenditure!=0, $opt
$est: $method sp_detrended $fixed $iv $cvs if $cond1, $opt
$est: $method $dv $fixed $iv2 $cvs if $cond1, $opt
$est: $method $dv $fixed $iv3 $cvs if $cond1, $opt
$est: $method $dv $fixed $iv $cvs if $cond1, $opt2
$est: $method $dv $ldv $iv $cvs if $cond1, $opt
$est: $method d.$dv $fixed $ldv $iv $cvs $dif if $cond1, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) keep($ldv $iv $iv2 $iv3 $cvs $dif _cons) ///
order($ldv $iv $iv2 $iv3 $cvs $dif _cons)
eststo clear

*************
* Table A23 *
*************

global confound "L.xhatmedian L.latent_personalism L.tr_ea5 L.fail5 L.ln_duration L.ln_protest"

$est: $method $dv $fixed $iv $cvs L.xhatmedian if $cond1, $opt
$est: $method $dv $fixed $iv $cvs L.latent_personalism if $cond1, $opt
$est: $method $dv $fixed $iv $cvs L.tr_ea5 if $cond1, $opt
$est: $method $dv $fixed $iv $cvs L.fail5 if $cond1, $opt
$est: $method $dv $fixed $iv $cvs L.ln_duration if $cond1, $opt
$est: $method $dv $fixed $iv $cvs L.ln_protest if $cond1, $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) ///
keep($iv $cvs $confound _cons) order($iv $cvs $confound _cons)
eststo clear

*************
* Table A24 *
*************

$est: $method $dv cr_1-cr_151 i.year c.proximity##c.proximity $cvs if $cond1 & l.gwf_duration<=10 , $opt
$est: $method $dv $fixed c.proximity##c.proximity $cvs if $cond1 & l.gwf_duration>10 , $opt

esttab, nogap comp se(3) b(3) r2 star(* 0.10 ** 0.05 *** 0.01) ///
keep($iv $cvs _cons) order($iv $cvs _cons)
eststo clear


************
* Figure 1 *
************

$method $dv $fixed $iv $cvs if $cond1, $opt

margins, at(proximity=(0(0.05)1)) force noestimcheck
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) ///
title("Effect of Proximity on social protection spending") ///
xtitle(Proximity to election) ytitle(Social protection spending (%)) ///
xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1) ylabel(7(1)10) scheme(s2mono) name(Figure_1, replace)


************
* Figure 2 *
************

global speech "proximity c.proximity#c.proximity L.v2x_freexp cL.v2x_freexp#c.proximity cL.v2x_freexp#c.proximity#c.proximity"

$method $dv $fixed $speech $cvs if $cond1, $opt

margins, at(proximity=(0(0.05)1) L.v2x_freexp=0.168) force noestimcheck
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election, size(5)) ytitle(Social protection spending (%), size(5)) /*
*/title("Low media freedom", size(6)) /*
*/xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") /*
*/ylabel(5(1)11) scheme(s2mono) name(med1, replace)

margins, at(proximity=(0(0.05)1) L.v2x_freexp=0.756) force noestimcheck
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election, size(5)) ytitle(Social protection spending (%), size(5)) /*
*/title("High media freedom", size(6)) /*
*/xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") /*
*/ylabel(5(1)11)scheme(s2mono) name(med2, replace)

graph combine med1 med2, rows(1) xsize(8) scheme(s2mono) /*
*/title("Effect of Proximity on social protection spending by media freedom", size(5)) name(Figure_2, replace)


*************
* Figure A1 *
*************

hist social_protection if _est_model1==1 , title("") xtitle(Social protection spending (%)) ///
scheme(s2mono) title(Distribution of social protection spending) freq name(figure_a1, replace)


*************
* Figure A2 *
*************

hist proximity if _est_model1==1 , xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") ///
xtitle(Proximity to election) scheme(s2mono) title(Distribution of Proximity: Country-level) ///
freq name(figure_a2, replace)


*************
* Figure A3 *
*************

twoway scatter social_protection proximity if _est_model1==1 ///
|| qfit social_protection proximity if _est_model1==1, ///
scheme(s2mono) ytitle(Social protection spending (%)) ///
title(Distribution of Proximity and Social Protection) legend(off) ///
xtitle(Proximity to election) name(figure_a3, replace)


*************
* Figure A4 *
*************

$method defense $fixed $iv $cvs if $cond1, $opt

margins, at(proximity=(0(0.05)1)) force noestimcheck
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Military spending (%)) /*
*/title("Effect of proximity on military spending") /*
*/xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") ylabel(10(1)13) scheme(s2mono) name(Figure_A4, replace)



*****************************
* INDIVIDUAL LEVEL ANALYSIS *
*****************************

cd "/Users/kangwookhan/Desktop/"

use "replication_data_individual", clear

global iv "c.proximity##c.proximity"
global cvs "Rural Age Female Education Poverty Radio Sociotropic Egocentric Winner MIP_Poverty ln_gdppc GDPgrowth"
global fix "i.Round"
global fix2 "i.Round i.ccode"
global cond "democracy==0 & ea==1"
global cond2 "polity2<6 & ea==1"
global reg "eststo: reg"
global reg2 "qui reg"
global mixed "eststo: mixed"
global mixed2 "qui mixed"
global opt "cluster(ccode) robust"

***********
* Table 3 *
***********

$mixed pca_redist $iv $fix if $cond || ccode: proximity
est store model1
$mixed pca_redist $iv $cvs $fix if $cond || ccode: proximity
test proximity c.proximity#c.proximity

$mixed pca_redist $iv $cvs $fix if $cond2 || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


*************
* Table A14 *
*************

$mixed pca_redist c.proximity##c.proximity##c.r_winner $fix if $cond || ccode: proximity
$mixed pca_redist c.proximity##c.proximity##c.r_winner $cvs $fix if $cond || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


*************
* Table A15 *
*************

$mixed pca_redist c.proximity##c.proximity##c.Radio if $cond || ccode: proximity
$mixed pca_redist c.proximity##c.proximity##c.Radio $cvs if $cond || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


*************
* Table A16 *
*************

$mixed pca_redist $iv $cvs $fix if $cond & govt_sponsor==0 || ccode: proximity
$mixed pca_redist $iv $cvs $fix if $cond & irr_elec!=1 || ccode: proximity
$mixed pca_redist $iv $cvs $fix if $cond & r_elec!=1 || ccode: proximity
$mixed pca_redist $iv $cvs $fix if $cond & fraud!=1 || ccode: proximity
$mixed pca_redist $iv $cvs $fix if $cond & nfraud!=1 || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


*************
* Table A17 *
*************

$mixed Q56B $iv $cvs $fix if $cond || ccode: proximity
$mixed Q56E $iv $cvs $fix if $cond || ccode: proximity
$mixed Q56J $iv $cvs $fix if $cond || ccode: proximity
$reg pca_redist $iv $cvs $fix2 if $cond, $opt

esttab, se(3) b(3) nogaps star(* 0.10 ** 0.05 *** 0.01) r2 
eststo clear


*************
* Table A18 *
*************

$mixed pca_redist $iv $fix if $cond & (COUNTRY!=9 & COUNTRY!=10 & COUNTRY!=32 & COUNTRY!=35) || ccode: proximity
$mixed pca_redist $iv $cvs $fix if $cond & (COUNTRY!=9 & COUNTRY!=10 & COUNTRY!=32 & COUNTRY!=35) || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


*************
* Table A25 *
*************

eststo: melogit easy_medical $iv $cvs if $cond || ccode: proximity
eststo: melogit easy_medical c.proximity##c.proximity##c.r_winner $cvs if $cond || ccode: proximity

esttab, comp se(3) b(3) star(* 0.10 ** 0.05 *** 0.01) nogaps r2 
eststo clear


************
* Figure 3 *
************

$mixed2 pca_redist $iv $cvs $fix if $cond || ccode: proximity
test proximity c.proximity#c.proximity

margins, at(proximity=(0(0.02)1)) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of gov't redistribution) /*
*/title("Effect of proximity on perception of gov't redistribution") xlabel(0(0.2)1) scheme(s2mono) /*
*/name(figure_3, replace)


************
* Figure 4 *
************

$mixed2 pca_redist c.proximity##c.proximity##c.r_winner $cvs $fix if $cond || ccode: proximity

margins, at(proximity=(0(0.05)1) r_winner=9.638554) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election, size(5)) ytitle(Perception of gov't redistribution, size(5)) /*
*/title("Low ruling-party support", size(6)) xlabel(0(0.2)1) ylabel(-1(1)2.5) scheme(s2mono) /*
*/name(w1, replace)

margins, at(proximity=(0(0.05)1) r_winner=65.70294) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election, size(5)) ytitle(Perception of Redistribution, size(5)) /*
*/title("High ruling-party support", size(6)) xlabel(0(0.2)1) ylabel(-1(1)2.5) scheme(s2mono) /*
*/name(w2, replace)

graph combine w1 w2 , ///
title(Effect of proximity on perception of gov't redistribution by ruling party support, size(5)) ///
rows(1) xsize(8) scheme(s2mono) name(figure_4, replace)


*************
* Figure A5 *
*************

hist pca_redist if _est_model1==1,  ///
xtitle(Perception of gov't redistribution) title(Distribution of perception of gov't redistribution) ///
scheme(s2mono) ylabel(0 "0" 5000 "5000" 10000 "10000" 15000 "15000", labs(3)) freq name(figure_a5, replace)


*************
* Figure A6 *
*************

hist proximity if _est_model1==1, xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") ///
xtitle(Proximity to election) title(Distribution of Proximity: Individual-level) ///
scheme(s2mono) ylabel(, labs(3)) freq name(figure_a6, replace)


*************
* Figure A7 *
*************

twoway scatter pca_redist proximity if $cond || qfit pca_redist proximity if $cond, ///
scheme(s2mono) , xlabel(0 "0" 0.2 "0.2" 0.4 "0.4" 0.6 "0.6" 0.8 "0.8" 1 "1") ///
title(Distribution of Proximity and perception of gov't redistribution, size(4)) ///
xtitle(Proximity to election) ytitle(Perception of gov't redistribution) legend(off) name(figure_a7, replace)


*************
* Figure A8 *
*************

$mixed2 pca_redist c.proximity##c.proximity##c.Radio $cvs if $cond || ccode: proximity

margins, at(proximity=(0(0.05)1) Radio=0) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of redistribution) /*
*/xlabel(0(0.2)1) ylabel(-1(1)2) scheme(s2mono) /*
*/ti("Never") plotregion(margin(0 0 0 0)) name(rad1, replace)

margins, at(proximity=(0(0.05)1) Radio=1) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of redistribution) /*
*/xlabel(0(0.2)1) ylabel(-1(1)2) scheme(s2mono) /*
*/ti("Less than once a month") plotregion(margin(0 0 0 0)) name(rad2, replace)

margins, at(proximity=(0(0.05)1) Radio=2) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of redistribution) /*
*/xlabel(0(0.2)1) ylabel(-1(1)2) scheme(s2mono) /*
*/ti("A few times a month") plotregion(margin(0 0 0 0)) name(rad3, replace)

margins, at(proximity=(0(0.05)1) Radio=3) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of redistribution) /*
*/xlabel(0(0.2)1) ylabel(-1(1)2) scheme(s2mono) /*
*/ti("A few times a week") plotregion(margin(0 0 0 0)) name(rad4, replace)

margins, at(proximity=(0(0.05)1) Radio=4) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Perception of redistribution) /*
*/xlabel(0(0.2)1) ylabel(-1(1)2) scheme(s2mono) /*
*/ti("Every day") plotregion(margin(0 0 0 0)) name(rad5, replace)

graph combine rad1 rad2 rad3 rad4 rad5, rows(2) scheme(s2mono) ///
title(Effect of Proximity on perception of gov't redistribution by media consumption, size(3.5)) ///
name(figure_a9, replace)


*************
* Figure A9 *
*************

qui melogit easy_medical $iv $cvs if $cond || ccode: proximity

margins, at(proximity=(0(0.05)1)) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Probability of easy access to health service) /*
*/title("Effect of proximity on easy access to health service", size(3.5)) xlabel(0(0.2)1) ylabel(0(0.2)1) scheme(s2mono) /*
*/name(figure_a9, replace)


**************
* Figure A10 *
**************

qui melogit easy_medical c.proximity##c.proximity##c.r_winner $cvs if $cond || ccode: proximity

margins, at(proximity=(0(0.05)1) r_winner=8.235) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Probability of easy access to health service) /*
*/title("Low ruling-party support", size(3.5)) xlabel(0(0.2)1) ylabel(0(0.2)1) scheme(s2mono) /*
*/name(mw1, replace)

margins, at(proximity=(0(0.05)1) r_winner=65.70294) l(95) force 
marginsplot, x(proximity) recast(line) ciopts(recast(rline) lcolor(black) lpattern(dash)) /*
*/xtitle(Proximity to election) ytitle(Probability of easy access to health service) /*
*/title("High ruling-party support", size(3.5)) xlabel(0(0.2)1) ylabel(0(0.2)1) scheme(s2mono) /*
*/name(mw2, replace)

graph combine mw1 mw2 , title("Effect of proximity on easy access to health service", size(3.5)) rows(3) ysize(9) scheme(s2mono) name(figure_a10, replace)


